package com.cwl.aircraft;

import java.awt.*;

/**
 * @program: cwl_aircraft
 * @description: 游戏物体超类
 * @author: ChenWenLong
 * @create: 2019-11-14 10:50
 **/
public class GameObject {
    Image img;
    double  x,y;
    int   speed;
    int  width, height;

    public  void  drawSelf(Graphics  g){
        g.drawImage(img, (int)x,(int) y, null);
    }

    public GameObject(Image img, double x, double y, int speed, int width, int height) {
        super();
        this.img = img;
        this.x = x;
        this.y = y;
        this.speed = speed;
        this.width = width;
        this.height = height;
    }

    public GameObject(Image img, double x, double y) {
        super();
        this.img = img;
        this.x = x;
        this.y = y;
    }

    public GameObject() {
    }

    /**
     * 返回物体所在的矩形。便于后续的碰撞检测
     * @return
     */
    public  Rectangle   getRect(){
        return  new Rectangle((int)x, (int)y, width, height);
    }
}
